package com.googlecode.loframework.view.components.accessibility
{
	import com.googlecode.loframework.view.IComponent;
	
	import flash.events.MouseEvent;
	
	import mx.core.Application;
	
	import org.puremvc.as3.patterns.mediator.Mediator;

	/**
	 * Links TripleA component in with PureMVC framework. 
	 * @author ~martin
	 * 
	 */
	public class TripleAMediator extends Mediator
	{
		private static var _count:int;
		private var _name:String = "TripleAMediator";;
		
		/**
		 * Constructor. 
		 * @param viewComponent
		 * 
		 */
		public function TripleAMediator(viewComponent:IComponent)
		{
			_name += String(_count);
			
			super(_name, viewComponent);
			
			_count ++;
		}
		
		/**
		 * Called by PureMVC. 
		 * 
		 */
		override public function onRegister():void
		{
			super.onRegister();
			viewRef.addEventListener(MouseEvent.CLICK, onFontsize);
	
		}
		
		/**
		 * Clean up. 
		 * 
		 */
		override public function onRemove():void
		{
			super.onRemove();
			viewRef.removeEventListener(MouseEvent.CLICK, onFontsize);

		}
		
		/**
		 * Triggered by user clicking on AAA buttons. 
		 * @param evt
		 * 
		 */
		protected function onFontsize(evt:MouseEvent):void
		{
			switch(evt.target.id)
			{
				case "normal":
					viewRef.smallText();
					break;
				case "medium":
					viewRef.mediumText();
					break;
				case "large":
					viewRef.largeText();
					break;
			}
		}
		
		/**
		 * Returns typed reference to component. 
		 * @return 
		 * 
		 */
		protected function get viewRef():TripleA
		{
			return viewComponent as TripleA;
		}
		
	}
}